package com.tjbklx1.pattern.memento.demo7;

import com.tjbklx1.pattern.memento.demo6.Originator;

public class Client {
	public static void main(String[] args) {
		// 定义出发起人
		Originator originator = new Originator();
		// 定义出备忘录管理员
		Caretaker caretaker = new Caretaker();
		
		// 初始化
		originator.setState1("中国");
		originator.setState2("强盛");
		originator.setState3("繁荣");
		System.out.println("===初始化状态===\n" + originator);
		// 创建两个备忘录
		caretaker.setMemento("001", originator.createMemento());
		
		// 修改状态值
		originator.setState1("软件");
		originator.setState2("架构");
		originator.setState3("优秀");
		System.out.println("\n===修改后状态===\n" + originator);
		
		// 修改状态值
		originator.setState1("1");
		originator.setState2("2");
		originator.setState3("3");
		caretaker.setMemento("002", originator.createMemento());
		
		// 恢复一个指定标记的备忘录
		originator.restoreMemento(caretaker.getMemento("001"));
		System.out.println("\n===恢复001后状态===\n" + originator);
		
		originator.restoreMemento(caretaker.getMemento("002"));
		System.out.println("\n===恢复002后状态===\n" + originator);
	}
}